
function getSearchParams(props) {
    let param = {};
    param.tradetype = window.presetVar.tradetype;
    param.pk_jkbx = props.form.getFormItemsValue("head", "pk_jkbx").value;
    param.jkbxr = props.form.getFormItemsValue("head", "jkbxr").value;
    param.receiver = props.form.getFormItemsValue("head", "receiver").value;
    param.bzbm = props.form.getFormItemsValue("head", "bzbm").value;
    param.djrq = props.form.getFormItemsValue("head", "djrq").value;
    param.dwbm = props.form.getFormItemsValue("head", "dwbm").value;
    if (props.form.getFormItemsValue("head", "pk_item").value) {
        param.pk_item = props.form.getFormItemsValue("head", "pk_item").value;
    } else {
        param.pk_item = "~";
    }
    let bodyBZ = [];
    let pk_items = [];
    param.bzbms = bodyBZ;
    param.pk_items = pk_items;
    window.cjkdata = param;
    return param
}
/**
 * 
 * @param {*} rate_category 当前汇率类型
 * @param {*} windowTypes 所有汇率类型
 * @returns Y：五种类型之一，N：非五种类型，-1：空
 */
function getZzhllxValue(rate_category = '',windowTypes){
    if(rate_category.display){
        let curType = windowTypes.find((item) => {
            return item.display === rate_category.display
        })
        let value = curType.value
        if(value == '0' || value == '1' || value == '2' || value == '3' || value == '4') return 'Y'
        return 'N'
    } else {
        return -1
    }
}

/**
 * 汇率适配逻辑
 * currentrow_bzbm:当前币种，
 * rate_category：汇率类型，
 * type: 'head',表单，'body‘，表体，
 * props:props
 * moduleId:当前页签
 * rowid:当前行
 */
 function zzhllxLogic(currentrow_bzbm,rate_category,type,props,moduleId,rowid){
    let zzbwb = window.presetVar.zzbwb //组织币种
    let ratecontorl = window.presetVar.ratecontorl   // 集团参数NC004 N 不允许修改，Y 允许修改
    let zzhllxValue = getZzhllxValue(rate_category,window.presetVar.zzhllxs)  // Y:五种中的一种，N:非五种，-1：空
    let editKeys = []
    let unEditKeys = []
    if(currentrow_bzbm && currentrow_bzbm.value == zzbwb){
        unEditKeys = ['bbhl','zzhllx']
        editKeys = ['zzhllyrq']
        if(zzhllxValue < 0){
            unEditKeys = ['zzhllyrq','bbhl','zzhllx']
            editKeys = []
            type == 'head' ? props.form.setFormItemsValue(presetVar.head.head1,{'zzhllyrq':{display: null, value: null}}) : props.cardTable.setValByKeyAndRowId(moduleId, rowid, 'zzhllyrq',{value:null, display: null}) //清空组织汇率来源日期
        }
    } else if( zzhllxValue =='Y' && ratecontorl == 'N'){  //缺少对应5种组织汇率类型及集团参数判断
        unEditKeys = ['bbhl']
        editKeys = ['zzhllyrq','zzhllx']
    }  else if(zzhllxValue < 0){
        unEditKeys = ['zzhllyrq']
        editKeys = ['bbhl','zzhllx']
        type == 'head' ? props.form.setFormItemsValue(presetVar.head.head1,{'zzhllyrq':{display: null, value: null}}) : props.cardTable.setValByKeyAndRowId(moduleId, rowid, 'zzhllyrq',{value:null, display: null}) //清空组织汇率来源日期
    } else{
        unEditKeys = []
        editKeys = ['bbhl','zzhllyrq','zzhllx']
    }
    if(type == 'head'){
        editKeys.forEach((item) => {
            props.form.setFormItemsDisabled('head',{[item]: false});
        })
        unEditKeys.forEach((item) => {
            props.form.setFormItemsDisabled('head',{[item]: true});
        })
    } else{
        props.cardTable.setEditableByRowId(moduleId, rowid, editKeys, true)
        props.cardTable.setEditableByRowId(moduleId, rowid, unEditKeys, false)
    }
     
}

export {
    getSearchParams,
    getZzhllxValue,
    zzhllxLogic
}